package priv.pattern.strategy;

// 我们手动设定一种策略，这样对象之后的行为将由我们所指定的策略而决定

// 策略接口
interface Strategy {
    void execute();
}

// 策略实现
class ConcreteStrategyA implements Strategy {
    @Override
    public void execute() {
        System.out.println("Executing Strategy A");
    }
}

// 策略实现
class ConcreteStrategyB implements Strategy {
    @Override
    public void execute() {
        System.out.println("Executing Strategy B");
    }
}

// 策略上下文
class Context {
    private Strategy strategy;

    public Context(Strategy strategy) {
        this.strategy = strategy;
    }

    public void executeStrategy() {
        strategy.execute();
    }
}